package operations;
public class Loader {
	public static String[] getArray(String string) {
		int numWords = 0;
		for(int i = 0; i < string.length(); i++) {
			if(string.charAt(i) == ' ') numWords++;
		}
		numWords++;  // the last word
		String[] returnArray = new String[numWords];
		int returnArrayIndex = 0;
		StringBuffer buffer = new StringBuffer();
		for(int i = 0; i < string.length(); i++) {
			if(string.charAt(i) == ' ') {
				returnArray[returnArrayIndex] = buffer.toString();
				returnArrayIndex++;
				buffer = new StringBuffer();
			} else {
				buffer.append(string.charAt(i));
			}
		}
		returnArray[returnArrayIndex] = buffer.toString();
		return returnArray;
	}
	public static Tree getTST() {
		Tree tst = new Tree();
		String[] currentStringArray;
		String definition = "Definition of the word ";
		
		currentStringArray = getArray(Dictionary.dictionaryString[0]);
		for(int i = 0; i < 48; i++) {
			currentStringArray = getArray(Dictionary.dictionaryString[i]);
			for(int j = 0; j < currentStringArray.length; j++) tst.save(currentStringArray[j], definition + currentStringArray[j] + ".");
		}
				return tst;
	}
}